#pragma once

#include <string>
#ifdef _UNICODE
#define tstring wstring
#else
#define tstring string
#endif
#include <vector>

class CIme
{
public:
	CIme();
	~CIme();
	
	void init(HWND hWnd);
	void release();
	void enable(BOOL e);

	BOOL getActiveMode(){return m_bActiveMode;}
	void setActiveMode(JNIEnv*env, jobject req);
	BOOL getPassiveMode(){return m_bPassiveMode;}
	void setPassiveMode(JNIEnv*env,jobject req,BOOL e);
	
	BOOL setCompositionWindow(JNIEnv* env,BOOL bPassiveMode);
	BOOL setCandidateWindow(JNIEnv*env,int i);

	void onNotify(JNIEnv*env,WPARAM cmd,LPARAM argv);
	void onEnable(JNIEnv*env,BOOL e);
	jobject onComposition(JNIEnv* env,LPARAM lParam);

protected:
	static int GetAttrVector(const BYTE* attr,int attrLen,int strLen,std::vector<int> &attrClause,std::vector<BYTE> &attrOut);
	int GetSubString(JNIEnv* env,int strLen,const int* clause,int clauseLen,const TCHAR *readstr,int readstrLen,
		const int *readclause,int readclauseLen,std::vector<jstring> &subStrings);
	int GetCompositionString(int id,std::tstring &str);
	int GetCompositionString(int id,std::vector<int>& clause);
	int GetCompositionString(int id,std::vector<BYTE>& attr);
	int GetCompositionString(int id,void** x);

	HIMC m_hImc;
	HWND m_hWnd;
	BOOL m_bActiveMode;
	BOOL m_bPassiveMode;
	BOOL m_bEnable;
	POINT m_posRelat;

	jobject m_ActiveInputMethodRequests;
	jobject m_PassiveInputMethodRequests;
};

